package com.xlabs.client;

import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.core.client.GWT;

/**
 * UserAccountService class.
 * @author a.akhavan.b
 */
@RemoteServiceRelativePath("UserAccountService")
public interface UserAccountService extends RemoteService {
    /**
     * Gets user's username.
     * @return user's username.
     */
    public String getNickName();

    /**
     * Utility/Convenience class. Use UserAccountService.App.getInstance() to access static instance of
     * UserAccountServiceAsync
     */
    public static class App {
        /**
         * singleton instance of UserAccountServiceAsync.
         */
        private static final UserAccountServiceAsync ourInstance;

        static {
            ourInstance = (UserAccountServiceAsync) GWT.create(UserAccountService.class);
            ((ServiceDefTarget) ourInstance).setServiceEntryPoint(GWT.getModuleBaseURL() + "UserAccountService");
        }

        /**
         * Static method for getting an instance of UserAccountServiceAsync/
         * @return User account service async object.
         */
        public static UserAccountServiceAsync getInstance() {
            return ourInstance;
        }
    }
}
